package com.wenjie.controller.sys;

import com.wenjie.original.entity.common.vo.RestBaseVo;
import com.wenjie.original.entity.vo.SysCodeTemp.SysCodeTempVo;
import com.wenjie.original.entity.vo.SysCodeTempGroup.*;
import com.wenjie.original.service.ISysCodeTempGroupService;
import com.wenjie.original.service.ISysCodeTempService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("后台用户管理")
@RestController
@RequestMapping("/api/sysCodeTemp")
public class SysCodeTempController {


    @Autowired
    private ISysCodeTempGroupService sysCodeTempGroupService;

    @Autowired
    private ISysCodeTempService sysCodeTempService;

    @ApiOperation("查询代码组模版接口")
    @PostMapping("/tempGroup/list")
    public RestBaseVo<SysCodeTempGroupVo.ResVo> groupList(@RequestBody @Validated SysCodeTempGroupVo.SelVo selVo) {
        return sysCodeTempGroupService.list(selVo, SysCodeTempGroupVo.ResVo.class);
    }

    @ApiOperation("查询代码组详情接口")
    @PostMapping("/tempGroup/detailById")
    public SysCodeTempGroupSelVo groupDetailById(@RequestBody Long sysCodeTempGroupId) {
        return sysCodeTempGroupService.detailById(sysCodeTempGroupId);
    }

    @ApiOperation("添加代码模版组")
    @PostMapping("/tempGroup/add")
    public void add(@RequestBody @Validated SysCodeTempGroupAddVo addVo) {
        sysCodeTempGroupService.saveTempGroup(addVo);
    }


    @ApiOperation("修改代码组模版接口")
    @PostMapping("/tempGroup/upById")
    public void upTempGroupById(@RequestBody @Validated SysCodeTempGroupUpOrAddVo.UpVo upVo) {
        sysCodeTempGroupService.updateById(upVo);
    }

    @ApiOperation("修改代码组模版接口")
    @PostMapping("/tempGroup/up")
    public void upTempGroup(@RequestBody @Validated SysCodeTempGroupUpVo upVo) {
        sysCodeTempGroupService.update(upVo);
    }

    @ApiOperation("删除代码组模版接口")
    @PostMapping("/tempGroup/del")
    public void delTempGroup(@RequestBody @Validated Long sysCodeTempGroupId) {
        sysCodeTempGroupService.delById(sysCodeTempGroupId);
    }


    @ApiOperation("查询代码模版接口")
    @PostMapping("/temp/list")
    public RestBaseVo<SysCodeTempVo.ResVo> list(@RequestBody @Validated SysCodeTempVo.SelVo selVo) {
        return sysCodeTempService.list(selVo, SysCodeTempVo.ResVo.class);
    }


}
